package com.hmall.order.config;

import org.springframework.amqp.core.*;
import org.springframework.amqp.rabbit.annotation.QueueBinding;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class RabbitMQConfig {

    @Bean
    public Queue OrderQueue(){
        return QueueBuilder.durable("order.queue") // 指定队列名称，并持久化
                .deadLetterExchange("dl.ttl.exchange") // 指定死信交换机
                .deadLetterRoutingKey("dl")
                .build();
    }

    @Bean  TopicExchange orderExchange(){
        return  new TopicExchange("order.topic");
    }

    @Bean  Binding bingQueue(){
        return BindingBuilder.
                bind(OrderQueue()).
                to(orderExchange())
                .with("order.create");
    }
}
